import { defineStore } from "pinia";
import { ref, reactive } from 'vue'

//第一个参数id一般和文件名相同，第二个参数配置项
export const useTabsStore = defineStore('tabs', () => {
    let activeTab = ref("/home")
    let tabs = reactive([
        {
            title: "首页",
            path: "/home"
        }
    ])    
    
    // 添加Tab
    function addTab(title, path) {
        if (!tabs.some(tab => tab.path === path)) {
            tabs.push({
                title,
                path
            })
        }
        activeTab = path
    }
    return { tabs, activeTab, addTab }
})
